# This file is licensed under the Apache License v2.0 with LLVM Exceptions.
# See https://llvm.org/LICENSE.txt for license information.
# SPDX-License-Identifier: Apache-2.0 WITH LLVM-exception

# Tests for LLVM libc math.h functions.

load("//libc/test:libc_test_rules.bzl", "libc_test")

package(default_visibility = ["//visibility:public"])

licenses(["notice"])

libc_test(
    name = "exception_status_test",
    srcs = ["exception_status_test.cpp"],
    libc_function_deps = [
        "//libc:feclearexcept",
        "//libc:feraiseexcept",
        "//libc:fetestexcept",
    ],
    deps = [
        "//libc:__support_fputil_fenv_impl",
    ],
)

libc_test(
    name = "rounding_mode_test",
    srcs = ["rounding_mode_test.cpp"],
    libc_function_deps = [
        "//libc:fegetround",
        "//libc:fesetround",
    ],
)

libc_test(
    name = "enabled_exceptions_test",
    srcs = ["enabled_exceptions_test.cpp"],
    libc_function_deps = [
        "//libc:feclearexcept",
        "//libc:feraiseexcept",
        "//libc:fetestexcept",
    ],
    tags = ["nosan"],
    deps = [
        "//libc:__support_common",
        "//libc:__support_fputil_fenv_impl",
        "//libc:__support_macros_properties_architectures",
        "//libc/test/UnitTest:fp_test_helpers",
    ],
)

libc_test(
    name = "feholdexcept_test",
    srcs = ["feholdexcept_test.cpp"],
    libc_function_deps = [
        "//libc:feholdexcept",
    ],
    tags = ["nosan"],
    deps = [
        "//libc:__support_common",
        "//libc:__support_fputil_fenv_impl",
        "//libc:__support_macros_properties_architectures",
        "//libc/test/UnitTest:fp_test_helpers",
    ],
)

libc_test(
    name = "exception_flags_test",
    srcs = ["exception_flags_test.cpp"],
    libc_function_deps = [
        "//libc:fegetexceptflag",
        "//libc:fesetexceptflag",
    ],
    deps = [
        "//libc:__support_fputil_fenv_impl",
    ],
)

libc_test(
    name = "feclearexcept_test",
    srcs = ["feclearexcept_test.cpp"],
    libc_function_deps = [
        "//libc:feclearexcept",
    ],
    deps = [
        "//libc:__support_fputil_fenv_impl",
    ],
)

libc_test(
    name = "feenableexcept_test",
    srcs = ["feenableexcept_test.cpp"],
    libc_function_deps = [
        "//libc:fedisableexcept",
        "//libc:feenableexcept",
        "//libc:fegetexcept",
    ],
    deps = [
        "//libc:__support_common",
        "//libc:__support_macros_properties_architectures",
    ],
)

libc_test(
    name = "feupdateenv_test",
    srcs = ["feupdateenv_test.cpp"],
    libc_function_deps = [
        "//libc:feupdateenv",
    ],
    deps = [
        "//libc:__support_fputil_fenv_impl",
    ],
)

libc_test(
    name = "getenv_and_setenv_test",
    srcs = ["getenv_and_setenv_test.cpp"],
    libc_function_deps = [
        "//libc:fegetenv",
        "//libc:fegetround",
        "//libc:fesetenv",
        "//libc:fesetround",
    ],
    deps = [
        "//libc:__support_fputil_fenv_impl",
    ],
)
